package com.jredu.other;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.quartz.Scheduler;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:applicationContext.xml"})
public class QuartzTest {
 
	@Test
	public void print(){
		
         try {
			 QuartzScheduleJob job = new QuartzScheduleJob();
			 job.setChildJobs(null);
			 job.setClazz(null);
			 job.setConcurrent("0");
			 job.setCronExpression("0/5 * * * * ?");
			 job.setDescription("QuartzScheduleJob");
			 job.setIsSpringBean("1");
			 job.setJobGroup(Scheduler.DEFAULT_GROUP);
			 job.setJobName("quartzSchedule");
			 job.setJobStatus("1");
			 job.setTargetMethod("printString");
			 job.setTargetObject("scheduleTest");
			 QuartzJobFactory.createSheduler(job);
			 Thread.sleep(60*1000);
//			 QuartzJobFactory.shutdown();
			 System.out.println("pauseTrigger");
			 QuartzJobFactory.unscheduleJob(job);
			 Thread.sleep(60*1000);
			 System.out.println("resumeTrigger");
			 QuartzJobFactory.resumeJob(job);
			 System.out.println("modifyJobCronExpression");
			 job.setCronExpression("0/1 * * * * ?");
			 QuartzJobFactory.modifyJobCronExpression(job);
			 Thread.sleep(60*1000);
			 System.out.println("任务是否启动:"+QuartzJobFactory.isStarted());
		} catch (Exception e) {
			e.printStackTrace();
		}    
	}
 
}

